<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="easyui-panel" title="${title}" style="width:100%;max-width:400px;padding:30px 60px;">
    <form id="menu_from" method="post" action="#">
        <input type="hidden" name="id" value="${menu.data.id}">
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="name" value="${menu.data.name} " style="width:100%" data-options="label:'菜单名称:',required:true">
        </div>
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="url" value="${menu.data.url}" style="width:100%" data-options="label:'URL:',required:true">
        </div>
    </form>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">提交</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">清空</a>
    </div>
</div>
<script>
    function submitForm() {
            var subUrl = "${pageContext.request.contextPath}/menu/datapost";
            if($("#menu_from").form('validate')){
                var JsonDate =  $.serializeObject($('#menu_from'));
                $.ajax({
                    type: "POST",
                    url: subUrl,
                    cache:false,
                    data:JSON.stringify(JsonDate),
                    dataType:"json",
                    contentType:"application/json;charset=UTF-8",
                    success: function(data){
                      if(data.errCode == 0){
                          $('#menu_tree').tree("reload");
                          parent.window.reload_index_tree();
                      }else{
                          $.messager.alert('警告','操作失败');
                      }

                    },
                    error:function(XMLHttpRequest, textStatus, errorThrown){
                        console.info(XMLHttpRequest);
                        console.info(textStatus);
                        console.info(errorThrown);
                    }
                });
            }

    }
    function clearForm() {
        $('#menu_from').form('clear');
    }
</script>
